<?php
declare (strict_types = 1);

namespace app\validate\common\order;

use app\model\communal\OrderConsultModel;
use think\Validate;

class ConsultValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => ['require', 'number', 'gt:0'],
        'multi_id' => ['require', 'number', 'gt:0'],
        'item_id' => ['require', 'number', 'gt:0'],
        'morph_id' => ['require', 'number', 'gt:0'],
        'consult_method' => ['require', 'in:1,2'],
        'purchase_min' => ['require', 'number', 'gt:0'],
        'expert_id' => ['require', 'number', 'gt:0'],

        /*
         * 付款
         */
        'payment_type' => ['require', 'in:1,2'],
        'is_coin' => ['require', 'in:1,2'],
        // 'deduct_coin' => ['number', 'egt:0'],

        /*
         * 报告
         */
        'report_judge' => ['require'],
        'report_is_spirit' => ['require', 'in:1,2'],
        'report_is_nerve' => ['require', 'in:1,2'],

        'page' => ['number', 'gt:0'],
        'page_size' => ['number', 'gt:0'],
    ];

    protected $field = [
        'id' => '订单',
        'multi_id' => '测试订单',
        'item_id' => '服务项目',
        'morph_id' => '多态标识',
        'consult_method' => '咨询方式',
        'purchase_min' => '咨询时长',
        'expert_id' => '专家',

        /*
         * 付款
         */
        'payment_type' => '付款方式',
        'is_coin' => '是否使用元心币',

        /*
         * 报告
         */
        'report_judge' => '初步判断',
        'report_is_spirit' => '是否可以排除精神病性问题',
        'report_is_nerve' => '是否可以排除神经病性问题',

        'page' => '当前页数',
        'page_size' => '每页条数',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [];

    /**
     * 场景
     * @var array
     */
    protected $scene = [
        'index' => ['page', 'page_size'],
        'read' => ['id'],
        'rr' => ['id'],
        'id' => ['id'],
        'repay' => ['id', 'payment_type', 'is_coin'],
        'report' => ['id', 'report_judge', 'report_is_spirit', 'report_is_nerve',],
        'interpreter' => ['multi_id', 'expert_id', 'payment_type', 'is_coin'],
        'consulting' => ['item_id', 'expert_id', 'consult_method', 'purchase_min', 'payment_type', 'is_coin'],
    ];

    /**
     * scene save
     *
     * @return $this
     */
    public function sceneSave()
    {
        return $this->only(OrderConsultModel::$saveColumn);
    }

    /**
     * scene update
     *
     * @return $this
     */
    public function sceneUpdate()
    {
        return $this->only(OrderConsultModel::$updateColumn);
    }

    /**
     * scene update
     *
     * @return $this
     */
    public function sceneItem()
    {
        return $this->only(['id']);
    }
}
